package cn.itcast.service.impl;

import cn.itcast.mapper.ReportMapper;
import cn.itcast.pojo.JobOption;
import cn.itcast.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;


    @Override
    public JobOption empJobData() {
        List<Map<String,Object>> mapList= reportMapper.empJobData();
        List<Object> job = mapList.stream().map(map -> map.get("job")).collect(Collectors.toList());
        List<Object> count = mapList.stream().map(map -> map.get("count")).collect(Collectors.toList());
        JobOption jobOption = JobOption.builder().jobList(job).dataList(count).build();
        return jobOption;
    }

    @Override
    public List<Map<String, Object>> empGenderData() {
        List<Map<String,Object>> mapList = reportMapper.empGenderData();

        return mapList;
    }
}
